<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0"/>
	<title>全国商机</title>
	<link rel="stylesheet" type="text/css" href="../../css/aui-win.css">
	<link rel="stylesheet" type="text/css" href="../../css/pullToRefresh.css">
<style>
.search{
	position: absolute;
	top: 4px;
	right: 10px;
}
.search img{
	width:20px;
	height:20px;
}
.publist img{
	width:20px;
	height:20px;
}
.publist{
	position: absolute;
	top: 4px;
	right: 45px;
}
a {
	text-decoration: none;
}
.navBox {
	height: 40px;
}
.navBox ul li {
	font-size: 16px;
	line-height: 40px;
	display: inline-block;
	margin-left: 1%;
	list-style: none;
}
.selected {
	color: #00ABFD;
	border-bottom: 1px solid #00ABFD;
}
.edit {
	position: absolute;
	right: 2.5%;
	color: #0078FF;
}
/*slide*/
 .swipe {
        overflow: hidden;
        visibility: hidden;
        position: relative;
    }
    .swipe-wrap {
        overflow: hidden;
       
    }
    .swipe-wrap > figure {
    	height:130px;
        float: left;
        width: 100%;
        position: relative;
        z-index: 77;
    }
    #slider {
        margin: 0px auto;
         position: fixed;
        top: 45px; 
        z-index:77;
    }

    figure {
        margin: 0;
    }
    .swipe-wrap img {
		height: 130px;
		width: 100%;
	}
    nav{
	    position: absolute;
		bottom: 12px;
		overflow: hidden;
		z-index:999;
		left:16%;
    }
    #position {
        text-align: center;
        list-style: none;
        margin: 0;
        padding: 0;
    }
    #position li {
        width: 6px;
        height: 6px;
        border-radius: 50%;
        background: #141414;
        margin: 0 2px;
        cursor: pointer;
        float:left;
    }
    #position li.on {
        background-color: #1293dc;
    }
/*设置内容区样式*/
body {
	min-width: 320px;
}
#wrapper {
	background-color: white;
}
#wrapper ul li {
	overflow: hidden;
}
#wrapper ul li a {
	display: block;
	overflow: hidden;
	padding: 10px 10px 10px 10px;
	border-bottom: 1px solid #d9d9d9;
}
#wrapper ul li a.active {
	background-color: #d9e4e9;
}
#img {
	float: left;
	width: 90px;
	height: 90px;
	border-radius: 4px;
}
#wrapper .content {
	width: 65%;
	margin-left: 100px;
	overflow: hidden;
}
#wrapper .content h2, #wrapper h2 {
	font-size: 16px;
	font-weight: 800;
	color: #00abfd;
	margin-bottom: 2px;
	white-space: nowrap;
	text-overflow: ellipsis;
	overflow: hidden;
}
a{
	color:#999;
}
#wrapper .content p {
	height: 20px;
	width: 100%;
	color: #333;
	font-size: 14px;
	word-wrap: break-word;
}
.content span{
	font-size:14px;
}
#wrapper .t .content div:after {
	content: "专题";
	background-color: #55abce;
	border: 1px solid #55abce;
	border-radius: 4px;
	color: #fff;
	font-size: 12px;
	padding: 2px 6px;
	float: right;
	height: 14px;
	line-height: 14px;
}
.time {
	float: right;
	right: 2.5%;
}
.lookicon {
	width:12px;
	height:12px;
}
.icon {
	padding: 0px 1px 0px 3px;
	width:12px;
	height:12px;
}
.warnLi{
	width:100%;
	height:300px;
	text-align: center;
}
.warnLi span{
	margin-top:140px;
	font-size:20px;
}
#wrapper{
	overflow:visible !important;
	height: 70%;
}
#wrapper{

}
</style>
</head>
<body>


	<div class="div_loding_img">
		数据加载中……
	</div>
	<header class="aui-bar aui-bar-nav aui-bar-yunzo" id="aui-header">
		<a class="aui-btn aui-bar-yunzo aui-pull-left" id="back" onclick="back_go()"> <span class="aui-iconfont aui-icon-left"></span></a>
		<div class="aui-title" id="title">
			全国商机
		</div>
		<a class="search" onclick="openSearch()"><img src="../../image/home/busess/chaxun.png"></a>
			
		<a class="aui-iconfont aui-icon-menu aui-pull-right"></a>
	</header>
	<div class="margin_div"></div>
	<div id="slider" class="swipe" style="visibility:visible;">
		    <div class="swipe-wrap">
		        
		    </div>
		    <nav>
			    <ul id="position">
			        <li class="on"></li>
			        <li class=""></li>
			        <li class=""></li>
			        <li class=""></li>
			        <li class=""></li>
			    </ul>
			</nav>
	</div>
	<div class="div_mrg"></div>
	<div id="wrapper">
		<ul  id="txtNewsList"></ul>
	</div>
<script src="../../script/iscroll.js"></script>
<script src="../../script/pullToRefresh.js"></script>
<script src="../../script/jquery-1.10.2.min.js"></script>
<script src="../../script/common.js"></script>
<script src="../../script/swipe.js"></script>
<script type="text/javascript">

//顶部展示图片数据集合
var arr_data=new Array();
var topDataArr;
//列表展示数据集合
var listDataArr;
//显示数据条数
var pagesize;
//当前数量
var curCount = 0;
var post;
getListData()

function getListData()
{	
	pagesize=5;
	post =basedata('busessinfo')+"&pagesize="+pagesize+"&type=1";
	arr_data=[];
	$(".div_loding_img").css("display","block");
	ajaxcocRequest('../../../api/group/getgroupbusinessinfolist', 'post', post, function(msg){
		if(msg.code ==100){
			obj = $('#txtNewsList');
			obj.html("");
			var html ="";
			var html1= '';
			var objs = [];
			var praisesSrc;
			var src;
			if(msg.datum.n1!=null)
			{
				var len = msg.datum.n1.length;
				listDataArr = new Array();
				curCount = curCount + len;
				for (var i = 0; i < len; i++) {
					var thisItem = msg.datum.n1[i];
					var li  = document.createElement("li");
					
					if (msg.datum.n1[i].n10 == 0) {
						praisesSrc = "../../image/home/busess/nozan.png";
					} else {
						praisesSrc = "../../image/home/busess/zan.png";
					}					
					if(thisItem.n1==null||thisItem.n1=="null"||thisItem.n1==""){
						busessImg='../../image/home/busess/yunzo_def.png';
					}else{
						busessImg=thisItem.n1.split(',')[0];
					}
					listDataArr[i] = [thisItem.n0, thisItem.n2, busessImg, thisItem.n5, thisItem.n3, thisItem.n4, thisItem.n7, thisItem.n8, thisItem.n9,thisItem.n11];
					html = '<li><a tapmode="active" onclick="openinfo(listDataArr,' + i + ')"><div class="logo"><img id="img" src="' + busessImg + '"/></div><div class="content"><h2>' + thisItem.n2+'</h2><p class="name">' + thisItem.n4 + '</p><p class="company">' + thisItem.n5 + '</p><img class="lookicon" src="../../image/home/busess/chakan.png"><span>' + thisItem.n7 + '</span><img class="icon" src="../../image/home/busess/pinglun.png"><span>' + thisItem.n8+'</span><img class="icon" src="' + praisesSrc + '"><span>' + thisItem.n9 +'</span><div class="time"><img class="icon" src="../../image/home/busess/shijian.png"><span>' + thisItem.n3 + '</span></div></div></a></li>';
						arr_data.push(thisItem.n0);
						obj.append(html);
						$("#txtNewsList img").error(function(){
							$("#txtNewsList img").attr("src","../../image/home/busess/yunzo_def.png")
						})
						wrapper.refresh();
				}
				
				$(".div_loding_img").css("display","none")
			}else{
				if(msg.datum.n0!=null){
					
					obj.html("<div style='width:20%;margin:40px 0 0 40%;'><img src='../../image/gantan.png' style='width:100%;'></div><p style='width:100%;text-align:center;margin-top:30px;color:#999;font-size:18px;'>没有更多的商机了！</p>");
				}
				else{
					obj.html("<div style='width:20%;margin:40px 0 0 40%;'><img src='../../image/gantan.png' style='width:100%;'></div><p style='width:100%;text-align:center;margin-top:30px;color:#999;font-size:18px;'>暂时还未发布任何商机！</p>");
				}	
				$(".div_loding_img").css("display","none")
			}
			if(msg.datum.n0!=null)
			{
				topDataArr = new Array();
				for (var j = 0; j < msg.datum.n0.length; j++) {
					var item=msg.datum.n0[j];
					topDataArr[j] = [item.n0,item.n3,item.n1.split(",")[0],item.n4,item.n5,item.n6,item.n7,item.n8,item.n9,item.n10];
					objs[j] = item.n1.split(",")[0];
				}
			}
			loadingimage(objs);
		}
		else{
			$(".div_loding_img").css("display","none")
			$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
			$(".pullUpLabel").css("display","none")
		}
		
	});
	
}
refresher.init({
	id:"wrapper",
	pullDownAction:Refresh,
	pullUpAction:Load
});
function Refresh(){
	window.history.go(0)
	
}
function Load(){
	pagesize=pagesize+5;
	post =basedata('busessinfo')+"&pagesize="+pagesize+"&type=1";
	$(".div_loding_img").css("display","block")
	ajaxcocRequest('../../../api/group/getgroupbusinessinfolist', 'post', post, function(msg){
		if(msg.code ==100){
			obj = $('#txtNewsList');
			var html ="";
			var html1= '';
			var praisesSrc;
			var src;
			if(msg.datum.n1!=null)
			{
				var len = msg.datum.n1.length;
				listDataArr = new Array();
				curCount = curCount + len;
				for (var i = 0; i < len; i++) {
					var thisItem = msg.datum.n1[i];
					var li  = document.createElement("li");
					
					if (msg.datum.n1[i].n10 == 0) {
						praisesSrc = "../../image/home/busess/nozan.png";
					} else {
						praisesSrc = "../../image/home/busess/zan.png";
					}					
					if(thisItem.n1==null||thisItem.n1=="null"||thisItem.n1==""){
						busessImg='../../image/home/busess/yunzo_def.png';
					}else{
						busessImg=thisItem.n1.split(',')[0];
					}
					listDataArr[i] = [thisItem.n0, thisItem.n2, busessImg, thisItem.n5, thisItem.n3, thisItem.n4, thisItem.n7, thisItem.n8, thisItem.n9,thisItem.n11];
					var tag=false;
					for(var j=0;j<arr_data.length;j++){
						if(thisItem.n0===arr_data[j]){
							tag=true;
							break;
						}
					}
					if(!tag){
						html = '<li><a tapmode="active" onclick="openinfo(listDataArr,' + i + ')"><div class="logo"><img id="img" src="' + busessImg + '"/></div><div class="content"><h2>' + thisItem.n2+'</h2><p class="name">' + thisItem.n4 + '</p><p class="company">' + thisItem.n5 + '</p><img class="lookicon" src="../../image/home/busess/chakan.png"><span>' + thisItem.n7 + '</span><img class="icon" src="../../image/home/busess/pinglun.png"><span>' + thisItem.n8+'</span><img class="icon" src="' + praisesSrc + '"><span>' + thisItem.n9 +'</span><div class="time"><img class="icon" src="../../image/home/busess/shijian.png"><span>' + thisItem.n3 + '</span></div></div></a></li>';
							arr_data.push(thisItem.n0);
							obj.append(html);
							$("#txtNewsList img").error(function(){
								$("#txtNewsList img").attr("src","../../image/home/busess/yunzo_def.png")
							})
							wrapper.refresh();

					}
				}
				$(".div_loding_img").css("display","none")
				if(pagesize>len){
					alert("没有更多的信息！")
				}
			}else{
				
				$(".div_loding_img").css("display","none")
			}
			
		}
		else{
			$("body").append('<div class="wuwang"><img src="../../image/iconfont-wangluo.png"><p>网络拥堵，信息塞车</p></div>')
		}
	});
wrapper.refresh();	
}
//定制的图片轮播函数
function initSlide() {
	var bullets = document.getElementById('position').getElementsByTagName('li');
	var slider =
        Swipe(document.getElementById('slider'), {
            auto: 5000,
            continuous: true,
            disableScroll : true,
    		stopPropagation : true,
            callback: function(pos) {
                var i = bullets.length;
                while(i--){
                    bullets[i].className = ' ';
                }
                bullets[pos].className = 'on';
            }
        });
}
/**
 * 展示轮播图片
 */
function loadingimage(objs)
{
	var len=objs.length;
	var html='';
	for(var i=0;i<len;i++){
		html+='<figure><div class="face faceInner"><a onclick="openinfo(topDataArr,' + i + ')"><img src="'+objs[i]+'" width="100%" height="100%" /></a></div></figure>';
	}
	var swipeWrap=$(".swipe-wrap");
	swipeWrap.append(html);
	initSlide();
	$(".div_mrg").height($(".swipe-wrap img").height())
}

function openSearch(){
	var localData =  window.localStorage;
	window.location ="busess_search.html";
}
function openpublish(){
	var localData =  window.localStorage;
	if($mtype=="guest")
		{
			alert("游客模式无权限使用[商机发布]功能！");
		}else{
	window.location ="../first_frame/busess_publish.html";
	}
}

function openinfo(arr,i){
	var localData =  window.localStorage;
	window.location ="../first_frame/busess_info.html?"+encodeURIComponent("infoid="+arr[i][0]+"&title="+arr[i][1]+"&logoImg="+arr[i][2]+"&bussCopny="+arr[i][3]+"&bussTime="+arr[i][4]+"&bussPub="+arr[i][5]+"&bussBrws="+arr[i][6]+"&bussComts="+arr[i][7]+"&bussPris="+arr[i][8]+"&isColltect="+arr[i][9]);
}

</script>
</body>
</html>